import myfetch from "../assets/myfetch"
import token from "./token"
import use from "./user"
let user = use.getMyInfo()
export default {
  getQ(id) {
    let param = {
      id
    }
    return myfetch.myget('/message/getQ', param)
  },
  getNews(id) {
    let param = {
      id
    }
    return myfetch.myget('/message/getNews', param)
  },
  getMyMessage(isNews) {
    let param = {
      id: token.getToken()
    }
    isNews?param.isNews=1:null
    return myfetch.myget('/message/getMyMessage', param)
  },
  getCanUp(workid) {
    let param = {
      pid: user.id,
      workid
    }
    return myfetch.myget('/message/getCanUp', param)
  },
  upQ(id, type, message) {
    let param = {
      id,
      type,
      token: token.getToken()
    }
    let body = {
      message
    }
    return myfetch.mypost('/message/upQ', param, body)
  },
  upNews(id, message) {
    let param = {
      id,
      token: token.getToken()
    }
    let body = {
      message
    }
    return myfetch.mypost('/message/upNews', param, body)
  },
  setWrite(id, setWrite,isNews) {
    let param = {
      id,
      setWrite
    }
    isNews?param.isNews=1:null
    return myfetch.myget('/message/setWrite', param)
  },
  setQImg(id, imgurls) {
    let param = {
      id
    }
    let body = {
      imgurls
    }
    return myfetch.mypost('/message/setQImg', param, body)
  },
  creat(id, fromid, uptime,isNews) {
    let param = {
      id,
      fromid,
      uptime
    }
    isNews?param.isNews=1:null
    return myfetch.myget('/message/create', param)
  },
}
